'use client';

/*
* 课程套餐
coursePackage:
{
    id: '578d0a2f-28d1-4784-a0dc-1d2bd079c43e',
    client_id: 'f3b3217c-b696-4a75-8189-61158355a4a4',
    course_type: 'group',
    total_count: 10,
    left_count: 9,
    price: 1010,
    branch_campus_id: 'a0ab600d-15d9-49b3-8ef2-32722bb37b39',
    coach_id: '5f9c4963-a584-4fe3-bbb1-f88810061e40',
    sales_commission_rate: 30,
    channel: 0,
    status: 'active',
    created_at: '2024-11-29T15:25:19.168253027+08:00',
    updated_at: '2024-11-29T10:38:47Z',
    memo: '过分的话'
  }
*/

export default function CoursePackageItem({ coursePackage, coaches }) {
  const coach = coaches.find(c => c.id === coursePackage.coach_id);
  const courseTypeMap = {
    'group': '团课',
    'private': '私教课'
  };
  
  return (
    <div className="border rounded-lg p-4 mb-4">
      <div className="flex justify-between items-center mb-2">
        <div className="text-lg font-semibold">
          {courseTypeMap[coursePackage.course_type]}
        </div>
        <div className="text-sm text-muted-foreground">
          剩余{coursePackage.left_count}/{coursePackage.total_count}节
        </div>
      </div>
      
      <div className="text-sm text-muted-foreground space-y-1">
        <div>教练: {coach?.name || '未指定'}</div>
        <div>价格: ¥{coursePackage.price}</div>
        {coursePackage.memo && (
          <div>备注: {coursePackage.memo}</div>
        )}
      </div>
    </div>
  )
}